package src;
import java.util.ArrayList;
public class Test {
    static int a;
    static ArrayList<String> ar ;
    public static void main(String[] args) {
       
        setInt(a, 10);
        System.out.println((a==0)?"Pass by value for Primitive":"Pass by ref for Primitive");

        initializeArrayListRef(ar, new ArrayList<String>());
        System.out.println((ar ==  null)?"Pass by value for ArrayList":"Pass by ref for ArrayList");

        Dog d = new Dog("Tommy");
        updateDogsName(d, "Johney");
        System.out.println((d.name.equals("Tommy"))?"Pass by value for custom type":"Pass by ref for custom type");

    }
    private static void initializeArrayListRef(ArrayList<String> ar2,
            ArrayList<String> arrayList) {
        ar2 = arrayList;//if its pass by ref then the reference in the parent method should be initialized

    }
    private static void updateDogsName(Dog d, String string) {
        d = new Dog(string);//if its pass by ref then the reference in the parent method should be updated
    }


    private static void setInt(int a2, int i) {
        a2 = i;    
    }

}

class Dog{
    public String name;
    public Dog(String name){
        this.name = name;
    }
}
